import React from "react";
import classNames from "classnames";
import "./FieldError.less";

export default class FieldError extends React.Component {
  render() {
    const { error } = this.props;

    return (
      <div className={classNames('wea-edc-form-error clearfix', { 'wea-edc-has-error': !!error })}>
        {this.props.children}
        {error && <p className='wea-edc-errmsg'>{error}</p>}
      </div>
    );
  }
}

FieldError.defaultProps = {
  error: ''
};